﻿<!DOCTYPE html>
<html>
<head>
    <!--<base href="../" />-->
    <meta charset="UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="/static/css/common/reset.css" />
    <link rel="stylesheet" href="/static/css/associate.css" />
    <link rel="stylesheet" href="/static/css/sweetalert.min.css" />
    <link rel="stylesheet" href="/static/js/simditor/styles/simditor.css" />
    <link rel="stylesheet" href="/static/js/simditor/styles/simditor-html.css" />
    <link rel="stylesheet" href="/static/css/jquery-validate.css" />
    <title>企业首页</title>
</head>
<body>
    <div class="associate" ng-app="myApp">
        <div id="divHeader"></div>
        <section class="assoc-content container clearfix">
            <div class="assoc-c-left fl">
                <div id="divNavigation"></div>
            </div>
            <div class="assoc-c-right fr" ng-controller="Ctrl">
                <form id="form">
                    <div class="assoc-cr-information" ng-model="names">
                        <div class="assoc-cr-resiveInfo file" style="margin-top: 0px">
                            <div class="assoc-crb-resiveList">
                                <label>企业名称： </label>
                                <div class="form_control">
                                    <input type="text" class="required" data-tip="请输入企业名称" data-valid="isNonEmpty" data-error="企业名称不能为空" placeholder="请输入企业名称" value="{{names.Name}} " name="name" />
                                </div>
                            </div>
                            <div class="assoc-crb-resiveList">
                                <label>企业负责人：</label>
                                <div class="form_control">
                                    <input type="text" class="required" data-tip="请输入企业负责人" data-valid="isNonEmpty" data-error="企业负责人不能为空" placeholder="请输入企业负责人" value="{{names.ChargeName}}" name="chargeName" />
                                </div>
                            </div>
                            <div class="assoc-crb-resiveList">
                                <label>企业类型： </label>
                                <div class="form_control">
                                    <select name="type" class="required" data-valid="isNonEmpty" data-tip="请选择企业类型" data-error="请选择企业类型" id="type">
                                        <option value="">请选择企业类型</option>
                                    </select>
                                </div>
                            </div>
                            <div class="assoc-crb-resiveList">
                                <label>行业类型： </label>
                                <div class="form_control">
                                    <select style="width: 207px;" class="required" data-valid="isNonEmpty" data-tip="请选择行业类型" data-error="请选择行业类型" name="jobType" id="jobType">
                                        <option value="">请选择行业类型</option>
                                    </select>
                                </div>
                            </div>
                            <div class="assoc-crb-resiveList">
                                <label>企业简介： </label>
                                <div class="form_control">
                                    <input type="text" class="required" data-tip="请输入企业简介" data-valid="isNonEmpty" data-error="企业简介不能为空" placeholder="请输入企业简介" value="{{names.Sign}}" name="sign" />
                                </div>
                            </div>
                            <div class="assoc-crb-resiveList">
                                <label>企业规模：</label>
                                <div class="form_control">
                                    <select style="width: 207px;" name="size" id="size">
                                        <option value="">请选择企业规模</option>
                                    </select>
                                </div>
                            </div>
                            <div class="assoc-crb-resiveList">
                                <label>企业官网：</label>
                                <div class="form_control">
                                    <input type="text" class="required" data-valid="isNonEmpty" data-tip="请填写企业官网" data-error="请填写企业官网" placeholder="请填写企业官网" value="{{names.CompanyHref}}" name="href" />
                                </div>
                            </div>
                            <div class="assoc-crb-resiveList">
                                <label>企业地址：</label>
                                <div class="form_control">
                                    <input type="text" class="required" data-valid="isNonEmpty" data-tip="请填写企业地址" data-error="请填写企业地址" placeholder="请填写企业地址" name="address" value="{{names.Address}}" />
                                </div>
                                <input type="hidden" placeholder="" name="from" value="update" />
                            </div>
                            <p class="assoc-crb-cardTitle file">重新提交营业执照<span class="colorRed"></span></p>
                            <div class="reg-tAccount-uploadBtns clearfix">
                                <div class="reg-taUploadBtns-left fl" id="reg-taUploadBtns-left">

                                    <a href="javascript:void(0)" class="reg-tauLeft-btn" name="">
                                        营业执照上传
                                        <div class="form_control file">
                                            <input type="file" data-valid="isNonEmpty" data-tip="请上传营业执照" data-error="请上传营业执照" name="License" class="reg-tauLeft-btnInput required regInchargeFile" />
                                        </div>
                                        <p class="reg-tauLeft-text">未上传</p>
                                    </a>

                                </div>
                                <div class="reg-taUploadBtns-right fr">
                                    <p class="pl5">请根据提供规范上传营业执照</p>
                                    <ul class="reg-tauRight-ul clearfix mt10" id="reg-tauRight-ul">
                                        <li>
                                            <img src="/static/images/register66.png" />
                                            <p>企业营业执照</p>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                            <input type="button" class="assoc-crb-btn file" id="btnSubmit" value="确认修改" />
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
    <div id="divFooter"></div>
    <script type="text/javascript" src="/static/js/ref/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="/static/js/self/common.js"></script>
    <script type="text/javascript" src="/static/js/ref/angular.min.js"></script>
    <script src="/static/js/ref/linq.min.js"></script>
    <script type="text/javascript" src="/static/js/ref/sweetalert.min.js"></script>
    <script src="/static/js/self/jquery-validate.js"></script>
    <script>

        common.validator($('form'));

        $("#divHeader").load("/wuc/header.html");
        $("#divFooter").load("/wuc/footer.html");
        $("#divNavigation").load("/wuc/navigation.html");

        function AfterCompleted(ctx) {
            if (ctx == null) {
                common.alertMessage("保存失败");
                return;
            }
            window.location = "/company/company/companyInfo.html";
        }

        common.CreateController({ name: 'Ctrl', url: '/api/Enterprise/GetCompany', objType: 'dict' });
        function ListBaseData(ctx, args) {
            if (ctx == "" || ctx == null) {
                common.alertMessage("基础数据错误！");
                return;
            }
            lstAmout = ctx.ResponseList;
            Enumerable.From(lstAmout).ForEach(function (obj) {
                $("#" + args).append("<option value='" + obj.RuleNO + "'>" + obj.Description + "</option>")
            })
        }

        $(document).ready(function () {
            common.commonAjax({ type: 'get', url: '/api/Util/ListBaseData?fun=CompanySize', sMethod: common.ListBaseData, args: "size" });
            common.commonAjax({ type: 'get', url: '/api/Util/ListBaseData?fun=CompanyIndustry', sMethod: ListBaseData, args: "jobType" });
            common.commonAjax({ type: 'get', url: '/api/Util/ListBaseData?fun=CompanyType', sMethod: ListBaseData, args: "type" });
        });
        common.ValidateFormJQ('form', 'btnSubmit', submitSecondStep)
        function submitSecondStep() {
            common.FormAjax({ type: 'Post', url: '/api/Enterprise/CreateOrUpdate', ID: "form", sMethod: AfterCompleted });
        };

        //设置账号信息选择文件
        $("#reg-taUploadBtns-left .regInchargeFile").on(' change', function () {

            /*var filePath = this.files;
            var files_val = '';
            files_val = "已上传：" + filePath[0].name;
            console.log(filePath);
            this.parentElement.parentElement.nextElementSibling.innerHTML = files_val;*/

            var $file = $(this);
            var index_ = $file.parent().parent().index();
            var li_ = $("#reg-tauRight-ul li");
            var fileObj = $file[0];
            var fileVal = fileObj.files[0].name;

            var fileSize = (fileObj.files[0].size / 1024).toFixed(1);
            if (!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(fileVal)) {
                alert("图片类型必须是.gif,jpg,jpeg,png,GIF,JPG,PNG中的一种")
                return false;
            } else if (fileSize > 1024) {
                alert("图片不能大于1M")
                return false;
            }

            var windowURL = window.URL || window.webkitURL;
            var dataURL;
            if (fileObj && fileObj.files && fileObj.files[0]) {
                dataURL = windowURL.createObjectURL(fileObj.files[0]);
                li_.eq(index_).find("img").attr('src', dataURL);
                this.parentElement.nextElementSibling.innerHTML = '已上传：' + fileObj.files[0].name;
            } else {

                dataURL = $file.val();
                var imgObj = document.getElementById("reg-tauRight-ul");
                var li_ = imgObj.getElementByTagName('li');
                // 两个坑:
                // 1、在设置filter属性时，元素必须已经存在在DOM树中，动态创建的Node，也需要在设置属性前加入到DOM中，先设置属性在加入，无效；
                // 2、src属性需要像下面的方式添加，上面的两种方式添加，无效；
                li_[index_].childNodes[0].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                li_[index_].childNodes[0].filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = dataURL;

            }

        });
    </script>
</body>

</html>
